class Solution {
public:
    struct comp
    {
        bool operator()(const vector<int>& a, const vector<int>& b)
        {
            return a[0] < b[0];
        }
    };
    int findLongestChain(vector<vector<int>>& pairs) {
        int n = pairs.size();
        sort(pairs.begin(), pairs.end(), comp());
        vector<int> dp(n, 1);
        for (int i = 1;i < n;i++)
        {
            for (int j = 0;j < i;j++)
            {
                if (pairs[j][1] < pairs[i][0])
                {
                    dp[i] = max(dp[i], dp[j] + 1);


                }
            }
        }
        int t = 1;
        for (auto e : dp)
        {
            t = max(e, t);
        }
        return t;
    }
};